<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>

    var array=[9,5,3,2,6,5,6,7,6,212,1,8];
    function mao(array) {
        for(var i=0;i<array.length;i++){
            for(var j=0,emp;j<array.length-i;j++){
                if(array[i]>array[i+j]){
                    emp=array[i];
                    array[i]=array[i+j];
                    array[i+j]=emp;
                }
            }
        }
    }

    var timeVal=0;
    var timeVal1=0;
    for(var t=0;t<100000;t++){
        var timeStart1=new Date();
        mao(array);
        //timeVal.push();
        timeVal+=(new Date()-timeStart1);
    }
    console.log("冒泡："+timeVal/100000);
    for(var t1=0;t1<100000;t1++){
        var timeStart2=new Date();
        array.sort(function (a,b) {
            return Number(a)-Number(b);
        })
        timeVal1+=(new Date()-timeStart2);
    }
    console.log("sort："+timeVal1/100000);

//
//    var timeStart=new Date();

//    console.log("sort："+(new Date()-timeStart));


</script>
</body>
</html>